using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public abstract class AnalysisDeclaration : AnalysisStatement
{
    protected AnalysisDeclaration(AnalysisBoundKinds boundKind, Declaration syntaxNode, AnalysisNode? parent) :
        base(boundKind, syntaxNode, parent)
    {
        Syntax = syntaxNode;
        NameIdentifier = AnalysisNodeFactory.Identifier(syntaxNode.NameIdentifier, this, null);
    }

    public override Declaration Syntax { get; }

    public AnalysisIdentifier NameIdentifier { get; }

    public override int ChildrenCount => 1;

    public override IEnumerable<AnalysisNode> GetChildren()
    {
        return [NameIdentifier];
    }

    internal override void AddChild(AnalysisNode child)
    {
        throw new NotSupportedException("AnalysisDeclaration cannot have children.");
    }
}
